Skip to content

Add support for gzip-compressed CPIO output#2253

Merged
codysoyland merged 4 commits into
chainguard-dev:mainfrom
lavishpal:build-cpio-gzip-support
Jun 29, 2026
Merged

Add support for gzip-compressed CPIO output#2253
codysoyland merged 4 commits into
chainguard-dev:mainfrom
lavishpal:build-cpio-gzip-support

Conversation

@lavishpal

Copy link
Copy Markdown
Contributor

This PR implement support for gzip-compressed CPIO archives when the output filename ends with .gz
Detect .gz output filenames and wrap the destination writer with a gzip writer
Ran the relevant go tests

@lavishpal lavishpal force-pushed the build-cpio-gzip-support branch from f692bf1 to 282b5a3 Compare June 1, 2026 23:28
@lavishpal

Copy link
Copy Markdown
Contributor Author

cc: @imjasonh

Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal lavishpal force-pushed the build-cpio-gzip-support branch from 282b5a3 to 15aa0c7 Compare June 4, 2026 14:09

@codysoyland codysoyland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Is this needed if you can just run the output to gzip?

Can you include tests?

Comment thread internal/cli/build-cpio.go Outdated
@lavishpal

Copy link
Copy Markdown
Contributor Author

implemented based on an existing TODO comment in the codebase "// TODO(mattmoor): Consider wrapping in a gzip writer if the filename ends in .gz"

Happy to add tests and fix the gzw.Close() error handling.

@lavishpal

Copy link
Copy Markdown
Contributor Author

also to add some context on the running two separate commands means the full uncompressed output hits disk before being compressed even piping avoids that but still requires gzip to present as a binary which may be not guaranteed on windows or in minimal/distroless build env

Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal

Copy link
Copy Markdown
Contributor Author

@codysoyland , i fixed gzw.Close() to return its error explicitly instead of using defer and also added tests covering both the .gz and non-.gz output paths.

@lavishpal lavishpal requested a review from codysoyland June 24, 2026 03:30

@codysoyland codysoyland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding tests! I made a few small suggestions.

Comment thread internal/cli/build_cpio.go
Comment thread internal/cli/build_cpio_test.go Outdated
Comment thread internal/cli/build_cpio_test.go Outdated
Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal lavishpal requested a review from codysoyland June 27, 2026 03:14
@lavishpal

Copy link
Copy Markdown
Contributor Author

I address all the changes you have suggested. Can you PTAL?

@codysoyland

Copy link
Copy Markdown
Contributor

Looks good, but it's failing a lint check Please run golangci-lint run --fix.

Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal lavishpal force-pushed the build-cpio-gzip-support branch from 889aac4 to e173a2b Compare June 29, 2026 16:30
@lavishpal

Copy link
Copy Markdown
Contributor Author

Ran the command golangci-lint run --fix which shows 0 isssues.

@codysoyland codysoyland merged commit 6f58188 into chainguard-dev:main Jun 29, 2026
25 checks passed
@lavishpal lavishpal deleted the build-cpio-gzip-support branch June 29, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants